package org.microservice.system.listenter;

import com.alibaba.fastjson.JSON;
import org.microservice.common.entity.SysLog;
import org.microservice.common.util.constant.MqQueueConstant;
import org.microservice.system.service.SysLogService;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Created with IntelliJ IDEA.
 * User: 齐丹枫
 * Date: 2018/7/23
 * Time: 10:37
 * To change this template use File | Settings | File Templates.
 * Description:
 */
@Component
@RabbitListener(queues = {MqQueueConstant.LOG_QUEUE})
public class LogReceiveListener {


    @Autowired
    private SysLogService sysLogService;


    @RabbitHandler
    public void receive(String sysLog){
        SysLog log = JSON.parseObject(sysLog, SysLog.class);

        sysLogService.insert(log);
    }





}
